package com.organizadorestudiantil;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ListadoCursos extends Activity {

	public AlertDialog.Builder dialogo;
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.listadocursos);		
		cargarCursos();
	}
	
	public void cargarCursos(){
		SQLiteDatabase db = this.openOrCreateDatabase("organizadordb", MODE_WORLD_READABLE, null);
		LinearLayout cLayout = (LinearLayout)findViewById(R.id.listCursos);		
		cLayout.removeAllViews();
    	Cursor c = db.rawQuery(" SELECT * FROM Curso ",null);	
       	
    	if (c.moveToFirst()) {
    		do {
    			TextView tv = new TextView(this);
    			tv.setText(c.getString(1));
    			tv.setTextSize(25);
    			tv.setTextColor(c.getInt(2));
    			tv.setBackgroundColor(Color.WHITE);
    			cLayout.addView(tv);
    		} while(c.moveToNext());
    	}    	
    	db.close(); 
	}
	
	public void addCurso(View v){
		Intent i = new Intent(this, ingresoCurso.class);
        startActivity(i);
	}
	
	public void refreshCursos(View v){
		cargarCursos();
	}
	
	public void eliminarCurso(View v){
		
	}
}
